import 'dart:io';

void main() {
  // 不推荐写法
  /*getFirstData().then((res) {
    print(res);
    getSecondData().then((res2) {
      print(res2);
      getThirdData().then((res3) {
        print(res3);
      });
    });
  });*/

  // 推荐写法1
  /*getFirstData()
      .then((res) {
        print(res);
        return getSecondData();
      })
      .then((res2) => getThirdData())
      .then((res3) => print(res3))
      .catchError((e) => print(e))
      .whenComplete(() => print("done"));*/

  // 推荐写法2
}

Future<String> getFirstData() {
  return new Future(() {
    sleep(new Duration(seconds: 1));
    return "first data-111111";
  });
}

Future<String> getSecondData() {
  return new Future(() {
    sleep(new Duration(seconds: 2));
    return "second data-222222";
  });
}

Future<String> getThirdData() {
  return new Future(() {
    sleep(new Duration(seconds: 3));
    return "third data-333333";
  });
}
